import Vue from 'vue'
import VueRouter from 'vue-router'

Vue.use(VueRouter)

import Mine from '../views/mine/mine.vue'

import Youhui from '../views/mine/youhui/youhui.vue'
import zhima from '../views/mine/ZMxingyong/ZMxingyong.vue'
import zhuce from '../views/mine/login/zhuce/zhuce.vue'
import login from '../views/mine/login/login.vue'
import Zhangdan from '../views/mine/zhangdan/zhangdan.vue'
import MyOrder from '../views/mine/myOrder/myOrder.vue'
import Tuizhu from '../views/mine/tuizhu/tuizhu.vue'
import Xuzhu from '../views/mine/xuzhu/xuzhu.vue'
import MyHeTong from '../views/mine/tuizhu/myHeTong/myHeTong.vue'
import Zhuanzhu from '../views/mine/zhangdan/zhuanzhu/zhuanzhu.vue'


import Ordinaryclean from '../views/LifeService/ordinaryClean/ordinary.vue'
import LifeService from '../views/LifeService/LifeService.vue'
import chuman from '../views/LifeService/chuman/chuman.vue'
import chargecard from '../views/LifeService/chargeCard/chargeCard.vue'
import nuanqi from '../views/LifeService/more/nuanqi/nuanqi.vue'
import roommate from '../views/home/Roommate.vue'
import location from '../views/home/Location.vue'
import banjia from '../views/banjia/banjia.vue'
import jiaxiu from '../views/jiaxiu/jiaxiu.vue'
import baojie from '../views/baojie/baojie.vue'

import TSjianYi from '../views/mine/myOrder/TSjianyi/TSjianyi.vue'

import Shop from '../views/shop/shop.vue'
import Xinpin from '../views/shop/xinpin/xinpin.vue'
import Gwc from '../views/shop/gwc.vue'
import Ershou from '../views/shop/ershou/ershou.vue'
import Xiangqin from '../views/shop/xiangqin.vue'
import ConfirmOrder from '../views/shop/confirmOrder.vue'
import ShopList from '../views/shop/shoplist.vue'
import Woshi from '../views/shop/woshi.vue'
import Wsgc from '../views/shop/wsgc.vue'


import Yuekan from '../views/mine/yuekan/yuekan.vue'
import Dianfei from '../views/LifeService/dianfei/dianfei.vue'
import More from '../views/LifeService/more/more.vue'
import Wangfei from '../views/LifeService/wangfei/wangfei.vue'

import Home from '../views/home/home.vue'
import Myshezhi from '../views/mine/myShezhi/myShezhi.vue'
import Community from '../views/home/Community.vue'

import current from '../views/home/hotsearch/Current.vue'

import First from '../views/first.vue'



import Dianshi from '../views/LifeService/more/nuanqi/dianshi.vue'
import Nuanqi from '../views/LifeService/more/nuanqi/nuanqi.vue'
import Ranqi from '../views/LifeService/more/ranqi/ranqi.vue'
import MyPJ from '../views/mine/yuekan/myPJ/myPJ.vue'
import House from '../views/home/hotsearch/House.vue'


import Mynews from '../views/home/Mynews.vue'
import Hotsearch from '../views/home/Hotsearch.vue'
import Nearby from '../views/home/hotsearch/Nearby.vue'



import Shoucang from '../views/mine/shoucang/shoucang.vue'

const routes = [
  {path:'/',redirect:'/home'},
  {
    path: '/shoucang',
    name: 'shoucang',
    component: Shoucang
  },
  {
    path: '/mine',
    name: 'Mine',
    component: Mine
  },
  {
    path: '/first',
    name: 'First',
    component: First
  },

  {
    path: '/youhui',
    name: 'Youhui',
    component: Youhui
  },
  {
    path: '/zm',
    name: 'Zm',
    component: zhima
  },
  {
    path: "/zhuce",
    name: 'zc',
    component: zhuce
  },
  {
    path: "/login",
    name: 'login',
    component: login
  },
  {
    path: '/zhangdan',
    name: 'zhangdan',
    component: Zhangdan
  },
  {
    path: '/myOrder',
    name: 'myOrder',
    component: MyOrder
  },
  {
    path: '/tuizhu',
    name: 'tuizhu',
    component: Tuizhu
  },

  {
    path: '/xuzhu',
    name: 'xuzhu',
    component: Xuzhu
  },
  {
    path: '/myHeTong',
    name: 'myHeTong',
    component: MyHeTong
  },
  {
    path: '/zhuanzhu',
    name: 'zhuanzhu',
    component: Zhuanzhu
  },
  {
    path: '/TSjianyi',
    name: 'TSjianyi',
    component: TSjianYi
  },
  {
    path: '/lifeservice',
    name: 'LifeService',
    component: LifeService,
  },
  {
    path: '/ordinaryclean',
    name: 'ordinaryclean',
    component: Ordinaryclean
  },
  {
    path: '/chuman',
    name: 'chuman',
    component: chuman
  },
  {
    path: '/chargecard',
    name: 'chargecard',
    component: chargecard
  },
  {
    path: '/nuanqi',
    name: 'nuanqi',
    component: nuanqi
  },
  {
    path: '/roommate',
    name: 'roommate',
    component: roommate
  },
  {
    path: '/location',
    name: 'location',
    component: location
  },
  {
    path: '/banjia',
    name: 'banjia',
    component: banjia
  },
  {
    path: '/jiaxiu',
    name: 'jiaxiu',
    component: jiaxiu
  },
  {
    path: '/baojie',
    name: 'baojie',
    component: baojie
  },


  {
    path: '/xuzhu',
    name: 'xuzhu',
    component: Xuzhu
  },
  {
    path: '/myHeTong',
    name: 'myHeTong',
    component: MyHeTong
  },
  {
    path: '/zhuanzhu',
    name: 'zhuanzhu',
    component: Zhuanzhu
  },

  {

    path: '/yuekan',
    name: 'yuekan',
    component: Yuekan
  },
  {
    path: '/dianfei',
    name: 'dianfei',
    component: Dianfei
  },
  {

    path: '/TSjianyi',
    name: 'TSjianyi',
    component: TSjianYi
  },
  {
    path: '/shop',
    name: 'shop',
    component: Shop,
  },
  {
    path: '/ershou',
    name: 'ershou',
    component: Ershou
  },
  {
    path: '/xinpin',
    name: 'xinpin',
    component: Xinpin
  },
  {
    path: '/gwc',
    name: 'gwc',
    component: Gwc
  },
  {
    path: '/xiangqin',
    name: 'xiangqin',
    component: Xiangqin
  },
  {
    path: '/confirmOrder',
    name: 'confirmOrder',
    component: ConfirmOrder
  },
  {
    path: '/shoplist',
    name: 'shoplist',
    component: ShopList
  },
  {
    path: '/woshi',
    name: 'woshi',
    component: Woshi
  },
  {
    path: '/wsgc',
    name: 'wsgc',
    component: Wsgc
  },

  {

    path: '/more',
    name: 'more',
    component: More
  },
  {
    path: '/wangfei',
    name: 'wangfei',
    component: Wangfei
  },

  {
    path: '/dianshi',
    name: 'dianshi',
    component: Dianshi
  },
  {
    path: '/nuanqi',
    name: 'nuanqi',
    component: Nuanqi
  },
  {
    path: '/ranqi',
    name: 'ranqi',
    component: Ranqi
  },
  {
    path: '/myPJ',
    name: 'myPJ',
    component: MyPJ
  },
  {
    path: '/house',
    name: 'house',
    component: House
  },



  {
    path: '/TSjianyi',
    name: 'TSjianyi',
    component: TSjianYi
  },
  {
    path: '/myShezhi',
    name: 'myShezhi',
    component: Myshezhi
  },
  {
    path: '/home',
    name: 'home',
    component: Home
  },
  {
    path: '/community',
    name: 'community',
    component: Community
  },
  {

    path: '/current',
    name: 'current',
    component: current
  },
  {
    path: '/mynews',
    name: 'mynews',
    component: Mynews
  },
  {
    path: '/hotsearch',
    name: 'hotsearch',
    component: Hotsearch
  },
  {
    path: '/nearby',
    name: 'nearby',
    component: Nearby
  },


]

const router = new VueRouter({
  routes
})

// 路由拦截
router.beforeEach((to,from,next)=>{
  let token = window.localStorage.getItem('myToken');
  if(token){
    next()
  }else{
    if(to.path=='/login'||to.path=='/zhuce'||to.path=='/first'){
      next()
    }else{
      // 让下一个跳转路径为first
      next({path:'/first'})
    }
  }
})
export default router